package com.crm.jpaandthymeleaf;

import com.crm.jpaandthymeleaf.service.RedisService;
import com.crm.jpaandthymeleaf.utils.RedisUtil;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.springframework.boot.test.context.SpringBootTest;
import redis.clients.jedis.Jedis;

import javax.annotation.Resource;

/**
 * @author 周敬
 * @version 1.0
 * @packageName com.crm.jpaandthymeleaf
 * @fileName JedisTestter
 * @createTime 2021/12/18-9:16-星期六
 * @lastModify 2021/12/18-9:16-星期六
 */
@SpringBootTest
public class JedisTestter {
    private Jedis jedis;

    @BeforeEach
    public void setup(){
        //连接服务器     host：地址，port：端口
        jedis = new Jedis("127.0.0.1",6379);
        //密码
//        jedis.auth("");
    }

    @Test
    public void testString(){
        //--------添加数据---------
        //向key--->name中放入value--->zhoujing
        jedis.set("name","zhoujing");
        System.out.println(jedis.get("name"));


        jedis.append("name","sidashuaige");
        System.out.println(jedis.get("name"));

        jedis.mset("name","l s p","age","18","add","cz");
        jedis.incr("age");
        System.out.println(jedis.get("name")+"-"+jedis.get("age")+"-"+jedis.get("add"));
    }

    @Resource
    private RedisService redisService;

    @Test
    public void test(){
        boolean set = redisService.set("aoligei", "I like you");
        System.out.println(set);
    }
}
